home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / vap / vsetup.asm < prev    next >
Assembly Source File  |  1996-07-10  |  8KB  |  421 lines

  1. ;*****************************************************************************
  2. ;*
  3. ;* Program Name:  VAP_Setup_Module
  4. ;*
  5. ;* Filename:      vsetup.asm
  6. ;*
  7. ;* Version:      1.0
  8. ;*
  9. ;* Programmers:      Bryan Sparks
  10. ;*
  11. ;* Comments:      This is the startup and setup code for VAPs.
  12. ;*
  13. ;*****************************************************************************
  14.     name    VAPSetUpAndStartModule
  15.  
  16. DGROUP    GROUP    _DATA
  17.  
  18. PGROUP    GROUP    _TEXT
  19.     assume cs:PGROUP
  20.  
  21. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  22. ;; TEXT definitions
  23. ;;    Define header, ESR routines, Handler routines, 
  24. ;;     and ProcessStart procedures
  25. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  26. _TEXT    segment public 'CODE'
  27.     ;VAP definitions
  28.     public    NetWareShellServices, ProcessControlServices
  29.     public     ConsoleControlServices, IPXSPXServices
  30.     
  31.     ;IPX/SPX Definitions
  32.     public    _ReceiveESRHandler, _SendESRHandler
  33.  
  34.     ;SAP Definitions
  35.     public    _SAPWaitESRHandler, _SAPAdvertiseESRHandler
  36.  
  37.     ;Handler front-ends
  38.     extrn    _ConsoleHandler: near, _DownHandler: near
  39.  
  40.     ;IPX/SPX ESR Externals
  41. ;;;;    extrn    _ReceiveESR: near, _SendESR: near
  42.     extrn    _SAPWaitESR: near, _SAPAdvertiseESR: near
  43.  
  44.  
  45.     ;VAP Header
  46.     Signature            db    'NWProc'
  47.     NetWareShellServices        dd    ?
  48.     ProcessControlServices        dd    ?
  49.     ConsoleControlServices        dd    ?
  50.     IPXSPXServices            dd    ?
  51.     VAPConsoleHandler        dd    ConsoleHandlerCALL
  52.     VAPDownHandler            dd    DownHandlerCALL
  53.     VAPConsoleOrDownDataSegment    dw    DGroup
  54.     VAPConnectionRequestFlag    dw    1        ;No connection
  55.     VAPNameString            db    'Name String', 64-($-VAPNameString) dup(0)
  56.     VAPConsoleKeyWordCount        dw    2
  57.     VAPKeyword1            db    'FIRST', 16-($-VAPKeyword1) dup(0)
  58.     VAPKeyword2            db    'SECOND', 16-($-VAPKeyword2) dup(0)
  59.     VAPSignOnMessage        db    'Sign-on message.', 0
  60.                     db    500-($-VAPSignOnMessage) dup(0)
  61.  
  62.  
  63. VAPStart    proc    near
  64.     mov    ax, DGroup
  65.     mov    di, 1            ;change segment to data (read/write)
  66.     call     dword ptr cs:ProcessControlServices
  67.     cli
  68.     mov    ax, DGroup
  69.     mov    ds, ax
  70.     mov    es, ax
  71.     mov    ss, ax
  72.     mov    ax, OFFSET DGroup:MainStackEnd     
  73.     mov    sp, ax
  74.     sti
  75.     call    _MAIN               
  76. VAPStart    endp
  77.  
  78. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  79. ;;  Spawned Process front-ends
  80. ;;    These set the process up by assigning the segment registers
  81. ;;    and assigning a stack to the process.
  82. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  83. ;;  The following lines will change as YOUR VAP dictates.
  84. ;;  You will need to have you own names, etc.
  85. ;;
  86. ;;  Note that you will also need to change the KEYWORDs and the
  87. ;;  Stack names at the bottom of this file.  
  88. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  89.     ;Process definitions
  90.     public    _FirstProcessStart
  91.     public    _SecondProcessStart
  92.  
  93.     extrn    _Main: near    
  94.     extrn    _FirstProcess: near
  95.     extrn    _SecondProcess: near
  96.  
  97. _FirstProcessStart    proc    near
  98.     cli
  99.     mov    ax, DGroup
  100.     mov    ds, ax
  101.     mov    es, ax
  102.     mov    ss, ax
  103.     mov    ax, OFFSET DGroup:FirstStackEnd     
  104.     mov    sp, ax
  105.     sti
  106.     call    _FirstProcess               
  107. _FirstProcessStart    endp
  108.  
  109. _SecondProcessStart    proc    near
  110.     cli
  111.     mov    ax, DGroup
  112.     mov    ds, ax
  113.     mov    es, ax
  114.     mov    ss, ax
  115.     mov    ax, OFFSET DGroup:SecondStackEnd     
  116.     mov    sp, ax
  117.     sti
  118.     call    _SecondProcess               
  119. _SecondProcessStart    endp
  120.  
  121. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  122. ;; Handler front-ends
  123. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  124.     assume    ds: DGroup
  125.  
  126. ConsoleHandlerCALL    proc    far
  127.     mov    _Keyword, ax
  128.     call    _ConsoleHandler
  129.     ret
  130. ConsoleHandlerCALL    endp
  131.  
  132.  
  133. DownHandlerCALL            proc    far
  134.     call    _DownHandler
  135.     ret
  136. DownHandlerCALL        endp
  137.  
  138.  
  139. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  140. ;; Event Service Routine front-ends
  141. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  142. _ReceiveESRHandler    proc    far
  143.     mov    ax, DGroup
  144.     mov    ds, ax
  145.     push    es
  146.     push    si
  147. ;;;    call    _ReceiveESR
  148.     add    sp, 4
  149.     ret    
  150. _ReceiveESRHandler    endp
  151.  
  152. _SendESRHandler    proc    far
  153.     mov    ax, DGroup
  154.     mov    ds, ax
  155.     push    es
  156.     push    si
  157. ;;;    call    _SendESR
  158.     add    sp, 4
  159.     ret    
  160. _SendESRHandler    endp
  161.  
  162. _SAPWaitESRHandler    proc    far
  163.     mov    ax, DGroup
  164.     mov    ds, ax
  165.     push    es
  166.     push    si
  167.     call    _SAPWaitESR
  168.     add    sp, 4
  169.     ret    
  170. _SAPWaitESRHandler    endp
  171.  
  172. _SAPAdvertiseESRHandler        proc    far
  173.     mov    ax, DGroup
  174.     mov    ds, ax
  175.     push    es
  176.     push    si
  177.     call    _SAPAdvertiseESR
  178.     add    sp, 4
  179.     ret    
  180. _SAPAdvertiseESRHandler    endp
  181.  
  182. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  183. ;; Misc Procedures
  184. ;;    MSC stack check fake-out
  185. ;;    IPX Functions
  186. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  187.     public    __CHKSTK
  188.     public    _IPXOpenSocket
  189.     public    _IPXCloseSocket
  190.     public     _IPXGetInternetworkAddress
  191.     public     _IPXSendPacket
  192.     public    _IPXListenForPacket
  193.     public    _IPXScheduleIPXEvent
  194.     public    _IPXCancelEvent
  195.     public    _IPXGetLocalTarget
  196.     public    _IPXRelinquishControl
  197.     public    _IntSwap
  198.  
  199. __CHKSTK    proc    near
  200.     pop    cx            ; get return offset
  201.     sub    sp,ax            ; allocate stack space
  202.     jmp    cx            ; return to cx
  203. __CHKSTK    endp
  204.  
  205. ;Parameters:
  206. ;    On Entry:    Pointer to socket to open
  207. ;            Socket Longevity
  208. ;    On Exit:    Error codes in AX
  209. _IPXOpenSocket    proc    near
  210.     push    bp
  211.     mov    bp, sp
  212.  
  213.     mov    bx, [bp+4]
  214.     mov    dx, [bx]
  215.     mov    ax, [bp+6]
  216.  
  217.     call    dword ptr cs: IPXSPXServices
  218.  
  219.     pop    bp
  220.     ret
  221. _IPXOpenSocket    endp
  222.  
  223. ;Parameters:
  224. ;    On Entry:    Socket Number
  225. ;    On Exit:    nothing
  226. _IPXCloseSocket    proc    near
  227.     push    bp
  228.     mov    bp, sp
  229.  
  230.     mov    dx, [bp+4]
  231.  
  232.     call    dword ptr cs: IPXSPXServices
  233.  
  234.     pop    bp
  235.     ret
  236. _IPXCloseSocket    endp
  237.  
  238.  
  239.  
  240. ;Parameters:
  241. ;    On Entry:    10 byte buffer
  242. ;    On Exit:    10 byte buffer will contain address
  243. _IPXGetInternetworkAddress    proc near
  244.     push     bp
  245.     mov     bp,sp
  246.  
  247.     mov    ax, DGroup
  248.     mov    es, ax
  249.     mov     bx, [bp+4]    
  250.     mov     si, bx
  251.     mov     bx, 09h
  252.     call    dword ptr cs: IPXSPXServices
  253.     push    ds
  254.     pop    es
  255.  
  256.     pop     bp
  257.     ret
  258. _IPXGetInternetworkAddress endp
  259.  
  260.  
  261. ;Parameters
  262. ;    On Entry:    Pointer to ECB
  263. _IPXSendPacket proc near
  264.     push     bp
  265.     mov     bp, sp
  266.  
  267.     mov    ax, DGroup
  268.     mov    es, ax
  269.     mov     bx, [bp+4]
  270.     mov     si, bx
  271.     mov     bx, 03h
  272.  
  273.     call    dword ptr cs: IPXSPXServices
  274.  
  275.     push    ds
  276.     pop    es
  277.  
  278.     pop     bp
  279.     ret
  280. _IPXSendPacket endp
  281.  
  282. ;Parameters
  283. ;    On Entry:    Pointer to ECB
  284. _IPXListenForPacket proc near
  285.     push     bp
  286.     mov     bp, sp
  287.  
  288.     mov    ax, DGroup
  289.     mov    es, ax
  290.     mov     bx, [bp+4]
  291.     mov     si, bx
  292.     mov     bx, 04h
  293.     call    dword ptr cs: IPXSPXServices
  294.     push    ds
  295.     pop    es
  296.  
  297.     pop     bp
  298.     ret
  299. _IPXListenForPacket endp
  300.  
  301. _IPXScheduleIPXEvent proc near
  302.     push     bp
  303.     mov     bp, sp
  304.  
  305.     mov    ax, DGroup
  306.     mov    es, ax
  307.     mov     bx, [bp+6]
  308.     mov     si, bx
  309.     mov     ax, [bp+4]
  310.     mov     bx, 05h
  311.  
  312.     call    dword ptr cs: IPXSPXServices
  313.  
  314.     push    ds
  315.     pop    es
  316.  
  317.     pop     bp
  318.     ret    
  319. _IPXScheduleIPXEvent endp
  320.  
  321.  
  322. ;Parameters
  323. ;    On Entry:    Pointer to ECB
  324. _IPXCancelEvent proc near
  325.     push     bp
  326.     mov     bp, sp
  327.  
  328.     mov    ax, DGroup
  329.     mov    es, ax
  330.     mov     bx, [bp+4]
  331.     mov     si, bx
  332.     mov     bx, 06h
  333.  
  334.     call    dword ptr cs: IPXSPXServices
  335.  
  336.     push    ds
  337.     pop    es
  338.  
  339.     pop     bp
  340.     ret
  341. _IPXCancelEvent endp
  342.  
  343. ;Parameters:
  344. ;    On Entry:    Pointer to 12 byte address
  345. ;            Pointer to 6 byte empty buffer
  346. _IPXGetLocalTarget    proc    near
  347.     push     bp
  348.     mov     bp,sp
  349.  
  350.     mov    ax, DGroup
  351.     mov    es, ax
  352.     mov     bx, [bp+4]    
  353.     mov     si, bx
  354.     mov    bx, [bp+6]
  355.     mov    di, bx
  356.     mov     bx, 02h
  357.  
  358.     call    dword ptr cs: IPXSPXServices
  359.  
  360.     push    ds
  361.     pop    es
  362.  
  363.     pop     bp
  364.     ret
  365. _IPXGetLocalTarget    endp
  366.  
  367. ;Parameters:
  368. ;    On Entry:    nothing
  369. ;    On Exit:    nothing
  370. _IPXRelinquishControl    proc    near
  371.     mov    bx, 0Ah
  372.     call    dword ptr cs: IPXSPXServices
  373.     ret
  374. _IPXRelinquishControl    endp
  375.  
  376.  
  377. ;Parameters:
  378. ;    On Entry:    Parameter to swap
  379. ;    On Exit:    Returns swapped integer in AX
  380. _IntSwap    proc    near
  381.     push    bp
  382.     mov    bp, sp
  383.     mov    ax, [bp+4]
  384.     xchg    ah, al
  385.     pop    bp
  386.     ret
  387. _IntSwap    endp
  388.  
  389. _TEXT    ends
  390.  
  391.  
  392. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  393. ;; Data definitions
  394. ;;    Define all stacks for all processes and also define keyword variable
  395. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  396. _DATA    SEGMENT word public 'DATA'
  397.     assume ds:DGROUP
  398.  
  399.     ;Stacks
  400.     dw    2000 dup (0)
  401.     MainStackEnd    label     word
  402.  
  403.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  404.     ;;  Here are the stacks appropiate for each process.
  405.     ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  406.     dw    2000 dup (0)
  407.     FirstStackEnd    label     word
  408.     dw    2000 dup (0)
  409.     SecondStackEnd    label     word
  410.  
  411.  
  412.     ;Keyword that will be used in C program
  413.     public    _Keyword
  414.  
  415.     _Keyword    dw     0
  416.  
  417.  
  418. _DATA    ENDS
  419.  
  420.     end    VAPStart
  421.